#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>

#define OBJECT_L7               1
#define OBJECT_L7_DEFAULT       2
#define OBJECT_FILTER           3
#define OBJECT_JAVA             4
#define OBJECT_MODULE           5
#define OBJECT_LUA              6
#define OBJECT_SSL              7

/* ip|port
 *  192.168.0.1|80
 *  |80
 *  192.168.0.1-192.168.0.50|80-1000
 */
char* contact_ipport(char *ip, char *port)
{
	char *local_str = NULL;
	if(ip!=NULL && port!=NULL) {
		local_str = malloc(strlen(ip) + strlen(port) + 2); 
		sprintf(local_str, "%s|%s", ip, port);
		free(ip);
		free(port);
	} else if(ip!=NULL) {
		local_str = ip;
	} else { /* port is not null */
		local_str = malloc(strlen(port) + 2); 
		sprintf(local_str, "|%s", port);
		free(port);
	}
	return local_str;
}

/* l7 ���� */
int l7_add(char *ip_proto, char *ip_addr, int port, char *l7_proto)
{
	printf("l7_add %s %s %d %s\n", ip_proto, ip_addr, port, l7_proto);
	return 0;
}

int l7_del(char *ip_proto, char *ip_addr, int port)
{
	printf("l7_del %s, %s, %d\n", ip_proto, ip_addr, port);
	return 0;
}

int filter_add(char *macaddr, char* ip_proto, char *src_ipportrange,char *dst_ipportrange)
{
	printf("filter_add mac=%s proto=%s sip_range=%s dip_range=%s\n", macaddr, ip_proto, src_ipportrange, dst_ipportrange);
	return 0;
}

int filter_del(char *macaddr, char* ip_proto, char *src_ipportrange, char *dst_ipportrange)
{
	printf("filter_del %s %s %s %s\n", macaddr, ip_proto, src_ipportrange, dst_ipportrange);
	return 0;	
}

int filter_clear()
{
	printf("filter_clear\n");
	return 0;
}


/* ip_addr==NULL ��ʾ localhost */
int java_setup(char *ip_proto, char *ip_addr, int port)
{
	printf("java_setup %s %s %d\n", ip_proto, ip_addr, port);
	return 0; 
}


int commit(int obj_type)
{
	printf("commit %d\n", obj_type);
	return 0;
}
int rollback(int obj_type)
{
	printf("rollback %d\n", obj_type);
	return 0;
}

/* export */
int export_pcap(char *ip_proto, char *ipaddr, int port)
{
	printf("export pcap %s %s %d\n", ip_proto, ipaddr, port);
	return 0;
}

/* print */
int print_system()
{
	printf("print system\n");
	return 0;
}
	
int print_memory()
{
	printf("print memory\n");
	return 0;
}	

int print_ct(char *l7_proto)
{
	printf("print ct %s\n", l7_proto);
	return 0;
}	

int print_topology()
{
	printf("print memory\n");
	return 0;
}	

int print_task()
{
	printf("print task\n");
	return 0;
}	

int print_module()
{
	printf("print module\n");
	return 0;
}
		
int print_server()
{
	printf("print server\n");
	return 0;
}

int print_filter()
{
	printf("print filter\n");
	return 0;	
}

int print_java()
{
	printf("print java\n");
	return 0;	
}
int print_l7()
{
	printf("print l7\n");
	return 0;
}

void print_help()
{
	printf("help\n");
}
